package com.crm.business.crm.service.impl;

import com.alibaba.fastjson.JSONObject;
import com.crm.business.crm.service.CrmExamineService;
import com.crm.business.crm.service.ICrmExamineLogService;
import com.crm.business.crm.service.ICrmExamineRecordService;
import com.crm.business.crm.service.ICrmExamineService;
import com.crm.business.examine.service.IExamineRecordService;
import com.crm.common.crm.entity.BO.CrmExamineData;
import com.crm.common.ka.core.feign.crm.entity.CrmSaveExamineRecordBO;
import com.crm.common.ka.core.feign.crm.entity.SimpleCrmInfo;
import com.crm.common.ka.core.feign.examine.entity.ExamineConditionDataBO;
import com.crm.common.ka.core.feign.examine.entity.ExamineMessageBO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service
public class CrmExamineCallServiceImpl implements CrmExamineService {

    @Autowired
    private ICrmExamineRecordService examineRecordService;
    @Autowired
    private ICrmExamineLogService examineLogService;
    @Autowired
    private ICrmExamineService examineService;

    public CrmExamineData saveExamineRecord(CrmSaveExamineRecordBO examineRecordBO){
        CrmExamineData crmExamineData = examineRecordService.saveExamineRecord(examineRecordBO.getType(), examineRecordBO.getUserId(), examineRecordBO.getOwnerUserId(), examineRecordBO.getRecordId(), examineRecordBO.getStatus());
        return crmExamineData;
    }

    public List<JSONObject> queryByRecordId(Integer recordId){
        return examineLogService.queryByRecordId(recordId);
    }

    public Boolean queryExamineStepIsExist(Integer categoryType){
        Boolean isExist = examineService.queryExamineStepByType(categoryType);
        return isExist;
    }

    public JSONObject queryExamineRecordList(Integer recordId,Long ownerUserId){
        JSONObject object = examineRecordService.queryExamineRecordList(recordId, ownerUserId);
        return object;
    }


    public Map<String, Object> getDataMapForNewExamine(ExamineConditionDataBO examineConditionDataBO){
        return examineRecordService.getDataMapForNewExamine(examineConditionDataBO);
    }


    public Boolean updateCheckStatusByNewExamine( ExamineConditionDataBO examineConditionDataBO){
        return examineRecordService.updateCheckStatusByNewExamine(examineConditionDataBO);
    }

    public void addMessageForNewExamine( ExamineMessageBO examineMessageBO){
        examineRecordService.addMessageForNewExamine(examineMessageBO);
    }


    public SimpleCrmInfo getCrmSimpleInfo(ExamineConditionDataBO examineConditionDataBO){
        return examineRecordService.getCrmSimpleInfo(examineConditionDataBO);
    }

    public String queryMessageTitleForSend( Integer categoryType,Integer recordId){
        String number = examineRecordService.queryMessageTitleForSend(categoryType,recordId);
        return number;
    }

    public Long queryMessageSubmitUserForSend( Integer categoryType,Integer recordId){
        Long submitUserId = examineRecordService.queryMessageSubmitUserForSend(categoryType,recordId);
        return submitUserId;
    }
}
